package net.fivegoods.entity.impl.slim3;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2011-03-20 23:13:45")
/** */
public final class MissionModelMeta extends org.slim3.datastore.ModelMeta<net.fivegoods.entity.impl.slim3.MissionModel> {

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.lang.Integer> category = new org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.lang.Integer>(this, "category", "category", java.lang.Integer.class);

    /** */
    public final org.slim3.datastore.ModelRefAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, org.slim3.datastore.ModelRef<net.fivegoods.entity.impl.slim3.MissionClientModel>, net.fivegoods.entity.impl.slim3.MissionClientModel> clientRef = new org.slim3.datastore.ModelRefAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, org.slim3.datastore.ModelRef<net.fivegoods.entity.impl.slim3.MissionClientModel>, net.fivegoods.entity.impl.slim3.MissionClientModel>(this, "clientRef", "clientRef", org.slim3.datastore.ModelRef.class, net.fivegoods.entity.impl.slim3.MissionClientModel.class);

    /** */
    public final org.slim3.datastore.UnindexedAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, com.google.appengine.api.datastore.Text> description = new org.slim3.datastore.UnindexedAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, com.google.appengine.api.datastore.Text>(this, "description", "description", com.google.appengine.api.datastore.Text.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.util.Date> end = new org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.util.Date>(this, "end", "end", java.util.Date.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.util.Date> entryDeadline = new org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.util.Date>(this, "entryDeadline", "entryDeadline", java.util.Date.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.lang.Integer> fixedNumber = new org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.lang.Integer>(this, "fixedNumber", "fixedNumber", java.lang.Integer.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel> place = new org.slim3.datastore.StringAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel>(this, "place", "place");

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.util.Date> start = new org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionModel, java.util.Date>(this, "start", "start", java.util.Date.class);

    private static final MissionModelMeta slim3_singleton = new MissionModelMeta();

    /**
     * @return the singleton
     */
    public static MissionModelMeta get() {
       return slim3_singleton;
    }

    /** */
    public MissionModelMeta() {
        super("MissionModel", net.fivegoods.entity.impl.slim3.MissionModel.class);
    }

    @Override
    public net.fivegoods.entity.impl.slim3.MissionModel entityToModel(com.google.appengine.api.datastore.Entity entity) {
        net.fivegoods.entity.impl.slim3.MissionModel model = new net.fivegoods.entity.impl.slim3.MissionModel();
        model.setCategory(longToInteger((java.lang.Long) entity.getProperty("category")));
        if (model.getClientRef() == null) {
            throw new NullPointerException("The property(clientRef) is null.");
        }
        model.getClientRef().setKey((com.google.appengine.api.datastore.Key) entity.getProperty("clientRef"));
        model.setDescription((com.google.appengine.api.datastore.Text) entity.getProperty("description"));
        model.setEnd((java.util.Date) entity.getProperty("end"));
        model.setEntryDeadline((java.util.Date) entity.getProperty("entryDeadline"));
        model.setFixedNumber(longToInteger((java.lang.Long) entity.getProperty("fixedNumber")));
        model.setKey(entity.getKey());
        model.setPlace((java.lang.String) entity.getProperty("place"));
        model.setStart((java.util.Date) entity.getProperty("start"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        net.fivegoods.entity.impl.slim3.MissionModel m = (net.fivegoods.entity.impl.slim3.MissionModel) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("category", m.getCategory());
        if (m.getClientRef() == null) {
            throw new NullPointerException("The property(clientRef) must not be null.");
        }
        entity.setProperty("clientRef", m.getClientRef().getKey());
        entity.setUnindexedProperty("description", m.getDescription());
        entity.setProperty("end", m.getEnd());
        entity.setProperty("entryDeadline", m.getEntryDeadline());
        entity.setProperty("fixedNumber", m.getFixedNumber());
        entity.setProperty("place", m.getPlace());
        entity.setProperty("start", m.getStart());
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        net.fivegoods.entity.impl.slim3.MissionModel m = (net.fivegoods.entity.impl.slim3.MissionModel) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        net.fivegoods.entity.impl.slim3.MissionModel m = (net.fivegoods.entity.impl.slim3.MissionModel) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        throw new IllegalStateException("The version property of the model(net.fivegoods.entity.impl.slim3.MissionModel) is not defined.");
    }

    @Override
    protected void assignKeyToModelRefIfNecessary(com.google.appengine.api.datastore.AsyncDatastoreService ds, java.lang.Object model) {
        net.fivegoods.entity.impl.slim3.MissionModel m = (net.fivegoods.entity.impl.slim3.MissionModel) model;
        if (m.getClientRef() == null) {
            throw new NullPointerException("The property(clientRef) must not be null.");
        }
        m.getClientRef().assignKeyIfNecessary(ds);
    }

    @Override
    protected void incrementVersion(Object model) {
    }

    @Override
    protected void prePut(Object model) {
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

    @Override
    protected boolean isCipherProperty(String propertyName) {
        return false;
    }

    @Override
    protected void modelToJson(org.slim3.datastore.json.JsonWriter writer, java.lang.Object model, int maxDepth, int currentDepth) {
        net.fivegoods.entity.impl.slim3.MissionModel m = (net.fivegoods.entity.impl.slim3.MissionModel) model;
        writer.beginObject();
        org.slim3.datastore.json.JsonCoder encoder = null;
        if(m.getCategory() != null){
            writer.setNextPropertyName("category");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getCategory());
        }
        if(m.getClientRef() != null && m.getClientRef().getKey() != null){
            writer.setNextPropertyName("clientRef");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getClientRef(), maxDepth, currentDepth);
        }
        if(m.getDescription() != null && m.getDescription().getValue() != null){
            writer.setNextPropertyName("description");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getDescription());
        }
        if(m.getEnd() != null){
            writer.setNextPropertyName("end");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getEnd());
        }
        if(m.getEntryDeadline() != null){
            writer.setNextPropertyName("entryDeadline");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getEntryDeadline());
        }
        if(m.getExecutionsRef() != null){
            writer.setNextPropertyName("executionsRef");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getExecutionsRef());
        }
        if(m.getFixedNumber() != null){
            writer.setNextPropertyName("fixedNumber");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getFixedNumber());
        }
        if(m.getKey() != null){
            writer.setNextPropertyName("key");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getKey());
        }
        if(m.getPlace() != null){
            writer.setNextPropertyName("place");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getPlace());
        }
        if(m.getStart() != null){
            writer.setNextPropertyName("start");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getStart());
        }
        writer.endObject();
    }

    @Override
    protected net.fivegoods.entity.impl.slim3.MissionModel jsonToModel(org.slim3.datastore.json.JsonRootReader rootReader, int maxDepth, int currentDepth) {
        net.fivegoods.entity.impl.slim3.MissionModel m = new net.fivegoods.entity.impl.slim3.MissionModel();
        org.slim3.datastore.json.JsonReader reader = null;
        org.slim3.datastore.json.JsonCoder decoder = null;
        reader = rootReader.newObjectReader("category");
        decoder = new org.slim3.datastore.json.Default();
        m.setCategory(decoder.decode(reader, m.getCategory()));
        reader = rootReader.newObjectReader("clientRef");
        decoder = new org.slim3.datastore.json.Default();
        decoder.decode(reader, m.getClientRef(), maxDepth, currentDepth);
        reader = rootReader.newObjectReader("description");
        decoder = new org.slim3.datastore.json.Default();
        m.setDescription(decoder.decode(reader, m.getDescription()));
        reader = rootReader.newObjectReader("end");
        decoder = new org.slim3.datastore.json.Default();
        m.setEnd(decoder.decode(reader, m.getEnd()));
        reader = rootReader.newObjectReader("entryDeadline");
        decoder = new org.slim3.datastore.json.Default();
        m.setEntryDeadline(decoder.decode(reader, m.getEntryDeadline()));
        reader = rootReader.newObjectReader("executionsRef");
        decoder = new org.slim3.datastore.json.Default();
        reader = rootReader.newObjectReader("fixedNumber");
        decoder = new org.slim3.datastore.json.Default();
        m.setFixedNumber(decoder.decode(reader, m.getFixedNumber()));
        reader = rootReader.newObjectReader("key");
        decoder = new org.slim3.datastore.json.Default();
        m.setKey(decoder.decode(reader, m.getKey()));
        reader = rootReader.newObjectReader("place");
        decoder = new org.slim3.datastore.json.Default();
        m.setPlace(decoder.decode(reader, m.getPlace()));
        reader = rootReader.newObjectReader("start");
        decoder = new org.slim3.datastore.json.Default();
        m.setStart(decoder.decode(reader, m.getStart()));
        return m;
    }
}